#! /bin/sh

filepath=$(cd ../public/js; pwd)
files=`ls $filepath`
for f in $files
do
	file=${filepath}"/"${f}	
	if [ -f $file ]
	then
		if [[ $f == *.min.js ]];then
			fileback=${file}.back			
			` sed "s/istc.instreet.cn/istc.monkey.instreet.cn/g" $file > $fileback `;
			if [ $? -eq 0 ];then
				` rm $file;mv $fileback $file `
				echo "$file has changed domain sucessfully"
			fi
		elif [[ $f == *.back ]];then
			ofile=${file%%".back"}
		  	` mv  $file $ofile `
		fi
	fi
done
echo "all the js files has changed domain"